package practise.alogrithm.hundredInterviewQuestions;

/**
 * Created by angela on 6/8/2014.
 */
public class RemoveCharactorFromStringBitBased {
    public static String removeCharactorFromString(String src, String sample){
        long toBeRemovedMap = 0l;
        long MASK = 1l;//note there must be a long, as we need to operate on a long number
        StringBuilder stringBuilder = new StringBuilder();
        for(char ch:sample.toCharArray()){
            toBeRemovedMap=toBeRemovedMap|(MASK<<(ch-'a'));
        }

        for(char ch:src.toCharArray()){
            if((toBeRemovedMap & (MASK<<(ch-'a')))==0){
                stringBuilder.append(ch);
            }
        }
        return stringBuilder.toString();
    }

    public static void main(String[] args){
        System.out.println("Result:"+removeCharactorFromString("GMR VAST2 is a professional solution to provide VAR calculation","aeiou"));
    }
}
